<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <th:block th:include="fragments/header :: header"/>
</head>
<body class="easyui-layout">
<div data-options="region:'center'" style="width: 100%">
    <form id="trophyForm" action="" method="post" style="padding-top: 10px;padding-left: 20px;" th:object="${trophyModel.trophy}">
        <input type="hidden" name="id" th:value="*{id}">
        <table width="90%">
            <tr>
                <td>名称:</td>
                <td>
                    <select class="easyui-combobox" id="trophyId" name="trophyId" style="width: 120px" data-options="animate:true,required:true">
                    </select>
                </td>
            </tr>
            <tr>
                <td>俱乐部:</td>
                <td>
                    <select class="easyui-combobox" id="clubId" name="clubId" style="width: 100px;" data-options="animate:true,required:true">
                    </select>
                </td>
            </tr>
            <tr>
                <td>教练:</td>
                <td>
                    <select class="easyui-combobox" id="coachId" name="coachId" style="width: 100px;" data-options="animate:true">
                    </select>
                </td>
            </tr>
            <tr>
                <td>赛季:</td>
                <td>
                    <select class="easyui-combobox" id="season" name="season" style="width: 120px" data-options="animate:true,required:true">
                    </select>
                </td>
            </tr>
        </table>
    </form>
</div>
<div data-options="region:'south',border:false">
    <div style="text-align: center">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">提交</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">取消</a>
    </div>
</div>
<script th:inline="javascript">
    /*<![CDATA[*/
    var clubId = /*[[${trophyModel.trophy.clubId}]]*/ "";
    var trophyId = /*[[${trophyModel.trophy.trophyId}]]*/ "";
    var coachId = /*[[${trophyModel.trophy.coachId}]]*/ "";
    var season = /*[[${trophyModel.trophy.season}]]*/ "";
    /*]]>*/
</script>
<script>
    function submitForm() {
        $("#trophyForm").form('submit',{
            url:'/markt/trophy/save',
            onSubmit:function () {
                return $(this).form('enableValidation').form('validate');
            },
            success:function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        });
    }

    function clearForm() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    $(function () {
        $("#trophyId").combobox({
            url: "/markt/enumManage/getEnumTree/?enumName=荣誉",
            valueField:'id',
            textField:'text',
            onLoadSuccess:function () {
                $("#trophyId").combobox('setValue',trophyId);
            }
        });

        $("#clubId").combobox({
            url: "/markt/club/getClubTree",
            valueField:'id',
            textField:'text',
            onLoadSuccess:function () {
                $("#clubId").combobox('setValue',clubId);
            }
        });

        $("#coachId").combobox({
            url: "/markt/coach/getCoachTree",
            valueField:'id',
            textField:'text',
            onLoadSuccess:function () {
                if (coachId!=""){
                    $("#coachId").combobox('setValue',coachId);
                }
            }
        });

        $("#season").combobox({
            url: "/markt/enumManage/getEnumTree/?enumName=赛季",
            valueField:'id',
            textField:'text',
            onLoadSuccess:function () {
                $("#season").combobox('setValue',season);
            }
        })
    })
</script>
</body>
</html>
